<template>
  <Card :bordered="false" dis-hover class="ivu-mt" >
    <Form ref="searchForm" :model="searchParam" :label-width="labelWidth" :label-position="labelPosition">
      <Row :gutter="24" type="flex" justify="start">
      
      <#list relation.table.columns as column>
      <#if (column.getType()=="varchar" && !column.primary &&column_index<3)>
        <Col v-bind="grid">
          <FormItem label="${column.comment}：" prop="${column.name}$VLK">
            <Input v-model="searchParam.${column.name}$VLK" placeholder="请输入${column.comment}"></Input>
          </FormItem>
        </Col>
       </#if>
       </#list> 
        <#if (relation.table.columns?size>2) >
        <template v-if="collapse">
        	<#list relation.table.columns as column>
        	<#if (column.getType()=="varchar" && !column.primary && column_index>2 && column_index<7) >
            <Col v-bind="grid">
                <FormItem label="${column.comment}：" prop="${column.name}$VEQ">
                	 <Input v-model="searchParam.${column.name}$VEQ" placeholder="请输入${column.comment}"></Input>
                </FormItem>
            </Col>
            </#if>
            </#list> 
        </template>
        </#if>
        <Col v-bind="grid" class="ivu-text-right">
             <FormItem prop="name">
                 <Button type="primary" @click="search('abGrid')">查询</Button>
                 <Button class="ivu-ml-8" @click="resetSearchForm()">重置</Button>
                 <#if relation.table.columns?size>2 >
                 <a v-font="14" class="ivu-ml-8" @click="collapse = !collapse">
                     <template v-if="!collapse">
                         展开 <Icon type="ios-arrow-down" />
                     </template>
                     <template v-else>
                         收起 <Icon type="ios-arrow-up" />
                     </template>
                 </a>
                 </#if>
             </FormItem>
         </Col>
      </Row>
    </Form>
    <Button icon="md-add" type="primary" :to="{ name:'${relation.tableKey}_edit', params:{$add:true}}" >新增</Button>
    <ab-action-btn icon="md-trash" v-show="selectedData.length" :data="selectedData" 
    				url="/${system}/${relation.tableKey}/remove" postKey="id" confimMsg="确认删除${relation.tableComment}吗？" :afterFn="searchAndClearSelected">批量删除</ab-action-btn>
    <ab-grid url="/${system}/${relation.tableKey}/listJson" ref="abGrid" v-model="selectedData" :searchParam="searchParam">
      <column type="selection" width="60" align="center"></column>
      <#list relation.table.columns as column>
		<#if (!column.primary)>
		<column title="${column.comment}" key="${column.key}" sort='${column.name}' ${genCodeUtil.getColumnIviewFormatter(column)}></column>
		</#if>
	  </#list>
			
      <column title="管理" temp="action" minWidth="100"></column>
      <template slot="action" scope="{row,index}">
      	<a send-action="删除" url="/${system}/${relation.tableKey}/remove?id={row.${relation.table.getPkKey()}}">删除</a>
             <Divider type="vertical" />
         <router-link :to="{ name:'form_preview', query:{key:'${formKey}',id:row.${relation.table.getPkKey()},backRouter:'${relation.tableKey}List'}}">编辑</router-link>
      </template>
	</ab-grid>
</Card>
</template>
<script>
  import Vue from 'vue'
  import gridPageMixin from '@/components/ab-grid/ab-grid-page-mixin.js'
  
  export default {
    name: '${relation.tableKey}List',
    mixins: [ gridPageMixin ]
  }
</script>
